package com.smedi.ismedi.progress.core.port.adapter.persistence.repository.impl;

import com.smedi.ismedi.personnel.api.dto.response.resp.PersonDetailResp;
import com.smedi.ismedi.progress.core.port.adapter.service.PersonRemoteService;
import com.smedi.ismedi.progress.core.domain.aggregatemodel.Person;
import com.smedi.ismedi.progress.core.domain.dto.PersonQuery;
import com.smedi.ismedi.progress.core.domain.repository.PersonRepository;
import com.smedi.ismedi.progress.core.port.adapter.convert.AdapterConverter;
import com.smedi.ismedi.personnel.api.dto.response.resp.PersonResp;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther Cookie
 * @date 2022/7/20
 */
@Service
@AllArgsConstructor
public class PersonRepositoryImpl implements PersonRepository {
    private final AdapterConverter adapterConverter;

    private final PersonRemoteService personRemoteService;

    @Override
    public Person getPersonOne(PersonQuery personQuery) {
        PersonResp personOne = personRemoteService.getPersonOne(personQuery);
        Person person = adapterConverter.personRespToPerson(personOne);
        return person;
    }

    @Override
    public List<Person> getPersonList(PersonQuery personQuery) {
        return adapterConverter.personRespToPerson(personRemoteService.getPersonList(personQuery));
    }

    @Override
    public List<PersonDetailResp> getPersonDetailList(PersonQuery personQuery) {
        return adapterConverter.personDetailRespToPerson(personRemoteService.getPersonDetailList(personQuery));
    }
}
